import 'package:flutter/cupertino.dart';
import 'package:mobx/mobx.dart';

import 'package:terminal_flutter_demo/pages/animated_widget_page.dart';
import 'package:terminal_flutter_demo/pages/animation_list_page.dart';
import 'package:terminal_flutter_demo/pages/base_widget_page.dart';
import 'package:terminal_flutter_demo/pages/button_type_page.dart';
import 'package:terminal_flutter_demo/pages/card_circle_aspect_page.dart';
import 'package:terminal_flutter_demo/pages/column_row_page.dart';
import 'package:terminal_flutter_demo/pages/dialog_page.dart';
import 'package:terminal_flutter_demo/pages/getX_page.dart';
import 'package:terminal_flutter_demo/pages/grid_view_page.dart';
import 'package:terminal_flutter_demo/pages/list_view_page.dart';
import 'package:terminal_flutter_demo/pages/localization_demo_page.dart';
import 'package:terminal_flutter_demo/pages/navigator_page.dart';
import 'package:terminal_flutter_demo/pages/page_view_page.dart';
import 'package:terminal_flutter_demo/pages/stack_align_page.dart';
import 'package:terminal_flutter_demo/pages/tab_bar_view_page.dart';
import 'package:terminal_flutter_demo/pages/widget_key_page.dart';
import 'package:terminal_flutter_demo/pages/wrap_page.dart';
import 'package:terminal_flutter_demo/pages/mobxpages/mobx_home_page.dart';

part 'app.g.dart';

class MobxAppStore = AppStoreBase with _$MobxAppStore;

abstract class AppStoreBase with Store {
  @observable
  bool isNavSwitch = true;

  @observable
  bool isDrawerSwitch = true;

  @observable
  int showIndex = 0;

  @observable
  int currentIndex = 0;

  @observable
  List<Widget> widgets = [
    const LocalizationDemoPage(),
    const MobxHomePage(),
    const AnimatedWidgetPage(),
    const AnimationListPage(),
    const WidgetKeyPage(),
    const SwiperPage(),
    const PageViewPage(),
    const DialogPage(),
    const BaseWidget(),
    ListViewPage(),
    ListViewResPage(),
    GridViewPage(),
    ColumnRowPage(),
    const StackAlignPage(),
    CardCircleAspect(),
    const ButtonTypePage(),
    const WrapPage(),
    TabBarViewPage(),
    NavigatorPage(
      title: '首页',
    ),
    const GetXPage(),
  ];

  @observable
  Widget? currendDrawerWidget;

  @computed
  Widget? get getShowPage {
    if (isDrawerSwitch && currendDrawerWidget != null) {
      return currendDrawerWidget;
    }
    if (isNavSwitch) {
      return widgets[currentIndex * 2];
    }
    return widgets[showIndex];
  }

  @action
  ad() {}
}
